package demo13;

import java.io.IOException;
import java.net.DatagramSocket;
import java.net.SocketException;
import java.util.HashMap;
import java.util.Map;

public class DicUdpEchoServer extends UdpEchoServer{
    Map<String,String> hash=new HashMap<>();
    public DicUdpEchoServer(int port) throws SocketException {
        super(port);

        hash.put("dog","小狗");
        hash.put("cat","小猫");
        hash.put("pig","小猪");
        hash.put("stupid","菲");
    }

    public String process(String request) {
        return hash.containsKey(request)?hash.get(request):"词典中不存在该单词";
    }

    public static void main(String[] args) throws IOException {
        DicUdpEchoServer server=new DicUdpEchoServer(9090);
        server.start();
    }
}
